package com.haiqi.config;

import com.haiqi.config.interceptor.I18nInterceptor;
import com.haiqi.config.interceptor.LoginInterceptor;
import com.haiqi.config.interceptor.RequestInterceptor;
import com.haiqi.config.interceptor.SafeAuthInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by hythzx on 2016/5/12.
 */

@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
        registry.addInterceptor(new I18nInterceptor()).addPathPatterns("/**");
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/manage/**");
        registry.addInterceptor(new SafeAuthInterceptor()).addPathPatterns("/manage/**");
        registry.addInterceptor(new RequestInterceptor()).addPathPatterns("/**");
        super.addInterceptors(registry);
    }
}
